package com.edu.exam.enums.grading;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 图表类型枚举
 *
 * 管理分析图表的类型分类
 *
 * @author System
 * @version 1.0.0
 */
public enum ChartType implements BaseEnum {

    /**
     * 柱状图
     */
    BAR("BAR", "柱状图"),

    /**
     * 折线图
     */
    LINE("LINE", "折线图"),

    /**
     * 饼图
     */
    PIE("PIE", "饼图"),

    /**
     * 散点图
     */
    SCATTER("SCATTER", "散点图"),

    /**
     * 热力图
     */
    HEATMAP("HEATMAP", "热力图"),

    /**
     * 雷达图
     */
    RADAR("RADAR", "雷达图"),

    /**
     * 箱线图
     */
    BOX_PLOT("BOX_PLOT", "箱线图"),

    /**
     * 直方图
     */
    HISTOGRAM("HISTOGRAM", "直方图"),

    /**
     * 面积图
     */
    AREA("AREA", "面积图"),

    /**
     * 漏斗图
     */
    FUNNEL("FUNNEL", "漏斗图");

    private final String code;
    private final String description;

    ChartType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    /**
     * 从代码创建枚举实例
     *
     * @param code 枚举代码
     * @return 对应的枚举实例
     * @throws IllegalArgumentException 如果代码无效
     */
    public static ChartType fromCode(String code) {
        for (ChartType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown ChartType code: " + code);
    }

    
    @Override
    public String toString() {
        return description;
    }
}